<template>
    <div class="layerRtb layerRtb-threecolumn">
        <three-title :title="{name:'现住址'}"></three-title>
        <div class="layerRtb-scroll thinScroll" v-scrollHeight="137">
            <div class="analyItem">
                <p class="analyItemTit tx-center">类型</p>
                <div class="analyItemCon">
                    <p class="col-md-12">
                        <span class="cLightGray pr8">类型</span>
                        <span ref="table">
                            <!-- <select id="typeID">
                <option value="0">类型</option>
                <option value="1">办公</option>
                <option value="2">餐饮</option>
                <option value="3">商业</option>
                <option value="4">酒店</option>
                <option value="6">教育</option>
                <option value="7">会所</option>
                </select> -->
                            <!-- <input name="check" class="selBtn" type="checkbox" :data-id="0">类型 -->
                            <span v-for="(item,index) in workType" :key="index">
                                <input name="check" class="selBtn" type="checkbox" :value="item.id" v-model="fuIds" @change="getTwoTypes($event)"/>{{item.name}}
                            </span>
                            <!--  <input name="check" class="selBtn "  type="checkbox"  value="" :data-id="1" @change="selectAllBtn(1)"/>办公
                <input name="check" class="selBtn" type="checkbox" :data-id="2" @change="selectAllBtn(2)">餐饮
                <input name="check" class="selBtn" type="checkbox" :data-id="3" @change="selectAllBtn(3)">商业
                <input name="check" class="selBtn" type="checkbox" :data-id="4" @change="selectAllBtn(4)">酒店
                <input name="check" class="selBtn" type="checkbox" :data-id="6" @change="selectAllBtn(6)">教育
                <input name="check" class="selBtn" type="checkbox" :data-id="7" @change="selectAllBtn(7)">会所
                <input name="check" class="selBtn" type="checkbox" :data-id="8" @change="selectAllBtn(8)">家装
                <input name="check" class="selBtn" type="checkbox" :data-id="9" @change="selectAllBtn(9)">别墅 -->
                        </span>
                    </p>

                </div>
            </div>
            <!-- 二级分类 -->
            <div v-if="this.fuIds === this.fuIds">
                <!-- <div>{{ this.twoTypeArr }}</div> -->
                <div class="analyItem" v-for="(item,index) in this.twoTypeArr" :key="index">
                    <p class="analyItemTit tx-center">{{ getTypeName(item[0].pid) }}</p>
                    <div class="analyItemCon">
                        <span class="provinceClass" v-for="(otem,ondex) in item " :key="ondex">
                            <input name="twoType_name" type="checkbox" :value="otem.twoType_id" v-model="twoIds" @change="getTypeValues($event,item[0].pid)" />{{otem.twoType_name}}
                        </span>
                    </div>
                </div>
            </div>

            <div class="analyItem">
                <p class="analyItemTit tx-center">地址</p>
                <div class="analyItemCon">
                    <span class="cLightGray pr8">现住址</span>
                    <span>
                        <p class="analyItemTit  ">
                            <select id="AddressProvinceId" class="width100" v-model="pemdmert" @change="zhuShiQu($event,1)">
                                <option value="0">请先选择省</option>
                                <option :value="item.provinceId" v-for="(item,index) in zhuSheng" :key="index">{{item.provinceName}}</option>
                            </select>
                        </p>
                        <p class="analyItemTit  ">
                            <select id="AddressCityId" class="width100" v-model="cityId" @change="zhuQuJu($event,1)">
                                <option value="0">请先选择市</option>
                                <option :value="item.cityId" v-for="(item,index) in zhuShi" :key="index">{{item.cityName}}</option>
                            </select>
                        </p>
                        <p class="analyItemTit ">
                            <select id="AddressCountyId" class="width100" v-model="quName" @change="AddressDetail = ''">
                                <option value="0">请先选择区</option>
                                <option :value="item.countyId" v-for="(item,index) in zhuQu" :key="index">{{item.countyName}}</option>
                            </select>
                        </p>
                        <p class="analyItemTit">
                            <input type="text" value="具体地址信息" class="width100" v-model="AddressDetail">
                        </p>
                    </span>
                </div>
            </div>


        </div>
        <div class="layerRtb-footer">
            <div class="analyItem">
                <p class="analyItemTit tx-center">综合</p>
                <div class="analyItemCon tx-center">
                    <input type="button" value="提交" class="uiBtn-normal uiBtn-blue SubmitBtn" @click="MappingButton()">
                </div>
            </div>
        </div>
    </div>
</template>
<script>import { mapGetters } from 'vuex'
// eslint-disable-next-line standard/object-curly-even-spacing
import { GetPersonnelMsgByCondition, getPmWorkAreaByUid, getUserInfoMateByuid, getAdressByUid, loadTransCity,
    GetProvinceMsg, getCityMsgByProvinceId, getCountyMsgByCityId, getAllCity, getDiquByCity,
    getPmUserInfoMatchCity, getTwoType } from '../../../../../projectFiles/Person/dynamicProject/Resources/Api'
import { updateUserTypeValueAndAddress, updateStageInfoByleId } from '../../Resources/Api/index'
export default {
    data () {
        return {
            userInfo: {},
            receipt: [],
            monthNow: 0, // 工龄
            arrery: [], // 用来判断是否选择了三个
            adress: [], // 详细地址
            sheng: [], // 跨地区
            zhuSheng: [], // 现住址的省
            zhuShi: [], // 现住址的市
            zhuQu: [], // 现住址的区
            pemdmert: '', // 绑定的现住址的省
            cityId: '', // 绑定的现住址的市
            quName: '', // 绑定的现住址的区
            area: [], // 地区（分司）
            zhuCity: [], // 点击地区出现的分区
            dqIds: [], // 将分区进行拼接
            zhuCitymens: {}, // 将分司赋值
            AddressDetail: '', // 具体地址
            ontype: '', // 获取的类型id 拼接
            typeValue: '', // 截取，之后的类型id
            dqIde: '', // 截取之后的地区id
            siIds: [], // 获取的分司id 拼接
            quIds: [], // 获取分区拼接
            kuaIds: [], // 获取的跨地区id 拼接
            cityQuId: [], // 获取市底下的区Id
            cityQuArray: [], // 市底下的区Id 的数组
            siIdsNameArray: [], // 各个地区详情的数组
            huixian: {},
            workType: [],
            xuanzhong: [],
            colony: [],
            quColony: [],
            xiaColony: [],
            currentType: [],
            quObject: {},
            twoTypeArr: [], // 类型的二级分类
            fuIds: [], // 父级id的数组
            twoType: [], // 查出来的类型的二级分类
            twoTypes: [], // 选中的二级分类
            twoArr: [],
            twoIds: [], // 选中的二级类型id的数组
            typeArr: [], // 所有类型的数组
            beijing: [11, 12, 49, 55, 69, 71, 120, 140, 141]
        }
    },
    created () {
        this.workTypeArray()
        this.PmWorkAreaByUid()
        this.GetPersonnelMsgByCondition() // 项目经理信息
        this.getUserInfoMateByuid() // 接单天数 投诉率
        this.getAdressByUid() // 详细地址
        this.loadTransCity() // 跨地区
        this.GetProvinceMsg() // 省
        this.AllCity()// 地区 updateUserInfoMappingMsg
        // this.currentType.forEach(pid => {
        //     this.getTwoType(pid)
        // })
        // this.getCityMsgByProvinceId()//市
        // this.getCountyMsgByCityId()//区
    },
    computed: {
        ...mapGetters(['leftInfo', 'updatePlate', 'rx'])
    },
    methods: {
        isShow () {

        },
        AllCity () {
            getAllCity({

            }).then(res => {
                this.area = res.data.Body
            }).catch(err => {
                console.log(err)
            })
        },
        GetPersonnelMsgByCondition () {
            GetPersonnelMsgByCondition({
                uid: this.leftInfo.uid,
                appCardNo: this.leftInfo.app_cardNo
            }).then(res => {
                this.userInfo = res.data.Body
                this.monthNow = this.datemonth(res.data.Body[0].workDate, new Date())
            }).catch(err => {
                console.log(err)
            })
        },
        getUserInfoMateByuid () {
            getUserInfoMateByuid({
                uid: this.leftInfo.uid
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    this.receipt = res.data.Body
                }
            }).catch(err => {
                console.log(err)
            })
        },
        getAdressByUid () {
            getAdressByUid({
                uid: this.leftInfo.uid
            }).then(res => {
                this.adress = res.data.Body
                if (res.data.Body[0]) {
                    this.pemdmert = res.data.Body[0].province_id

                    this.cityId = res.data.Body[0].city_id

                    this.quName = res.data.Body[0].county_value

                    this.AddressDetail = res.data.Body[0].now_address
                } else {
                    this.pemdmert = 0

                    this.cityId = 0

                    this.quName = 0

                    this.AddressDetail = '具体地址信息'
                }
                this.zhuShiQu()
                this.zhuQuJu()
            }).catch(err => {
                console.log(err)
                this.$message('失败')
            })
        },
        loadTransCity () {
            loadTransCity({

            }).then(res => {
                this.sheng = res.data.Body
            }).catch(err => {
                console.log(err)
                this.$message('失败')
            })
        },
        GetProvinceMsg () {
            GetProvinceMsg({

            }).then(res => {
                this.zhuSheng = res.data.Body
                this.zhuShiQu()
            }).catch(err => {
                console.log(err)
                this.$message('失败')
            })
        },

        // 计算日期之间的月数
        datemonth (date1, date2) {
            // 拆分年月日
            date1 = date1.split('-')
            // 得到月数
            date1 = parseInt(date1[0]) * 12 + parseInt(date1[1])
            // 得到月数
            this.monthNow = parseInt(date2.getFullYear() * 12) + parseInt(date2.getMonth() + 1)

            var m = Math.abs(this.monthNow - date1)

            return m
        },
        // selectAllBtn (event, e) {
        //     let inputDom = document.getElementsByClassName('selBtn')
        //     // 是否被选中
        //     if (event.target.checked) {
        //         this.arrery.push(e)
        //         this.getTwoTypes(e)
        //         // if (this.arrery.length <= 4) {
        //         //     for (var i = 0, lens = inputDom.length; i < lens; i++) {
        //         //         inputDom[i].disabled = false
        //         //     }

        //         //     // var obj = {}
        //         //     // obj.press = e
        //         //     this.arrery.push(e)
        //         //     alert(this.arrery)
        //         //     // this.ontype += e + ','
        //         //     // this.typeValue = this.ontype.substring(0, this.ontype.length - 1)
        //         //     if (this.arrery.length >= 3) {
        //         //         for (var k = 0, len = inputDom.length; k < len; k++) {
        //         //             if (!inputDom[k].checked) {
        //         //                 inputDom[k].disabled = true
        //         //             }
        //         //         }
        //         //     }
        //         // } else {
        //         //     for (var j = 0, len3 = inputDom.length; j < len3; j++) {
        //         //         if (!inputDom[j].checked) {
        //         //             inputDom[j].disabled = true
        //         //         }
        //         //     }
        //         //     this.$message('只能选四个')
        //         // }
        //     } else {
        //         const currentIndex = this.arrery.findIndex((item) => { return item === e })
        //         this.arrery.splice(currentIndex, 1)
        //         for (var h = 0, lengths = inputDom.length; h < lengths; h++) {
        //             inputDom[h].disabled = false
        //         }
        //     }
        //     if (this.arrery.length === 4) {
        //         for (var j = 0, len3 = inputDom.length; j < len3; j++) {
        //             if (!inputDom[j].checked) {
        //                 inputDom[j].disabled = true
        //             }
        //         }
        //     }
        //     // if (this.arrery.length <= 2) {
        //     //     var obj = {}
        //     //     obj.press = e
        //     //     this.arrery.push(obj)
        //     //     this.ontype += e + ','
        //     //     this.typeValue = this.ontype.substring(0, this.ontype.length - 1)
        //     // } else {(

        //     //     console.log('失败')
        //     //     this.$message('只能选三个')
        //     // }
        // },
        // 通过父id查询所有二级分类
        getTwoType (pid) {
            getTwoType({
                pid: pid // 二级分类的id
            }).then(result => {
                this.twoType = result.data.Body.twoType
                if (this.twoType.length > 0) {
                    this.twoTypeArr.push(this.twoType)
                }
            }).catch(err => {
                console.log(err)
                console.log('提交失败')
            })
        },
        zhuShiQu (event, flag) {
            if (flag === 1) {
                this.cityId = ''
                this.quName = ''
                this.AddressDetail = ''
            }

            getCityMsgByProvinceId({
                provinceId: this.pemdmert
            }).then(res => {
                this.zhuShi = res.data.Body
                this.zhuQuJu()
            }).catch(err => {
                console.log(err)
                this.$message('提交失败')
            })
        },
        zhuQuJu (event, flag) {
            if (flag === 1) {
                this.quName = ''
                this.AddressDetail = ''
            }
            getCountyMsgByCityId({
                cityId: this.cityId
            }).then(res => {
                this.zhuQu = res.data.Body
            }).catch(err => {
                console.log(err)
                this.$message('提交失败')
            })
        },
        zhuShiByCityId (event) { /* 地区点击显分司 */
            if (event.target.checked) {
                this.dqIds.push(Number(event.target.value))
                this.getDiquByCity(event.target.value)
            } else {
                if (this.dqIds.length > 0) {
                    const currentIndex = this.dqIds.indexOf(Number(event.target.value))
                    if (currentIndex >= 0) {
                        this.dqIds.splice(currentIndex, 1)
                    }
                }
                const value = event.target.value
                let ArrayIndex
                this.zhuCity.forEach((item, index) => {
                    const currentIndex = item.findIndex((item) => {
                        return item.dq_lishu === Number(value)
                    })
                    if (currentIndex >= 0) {
                        ArrayIndex = index
                    } else {
                        return false
                    }
                })
                this.zhuCity.splice(ArrayIndex, 1)
            }
        },
        // 地区显示
        getDiquByCity (value) {
            getDiquByCity({
                dqId: value
            }).then(res => {
                res.data.Body.forEach(item => {
                    this.zhuCitymens = item
                })
                if (this.zhuCitymens.length > 0) {
                    this.zhuCity.push(this.zhuCitymens)
                }
                // this.getCityQuArrayDate(this.dqIde);
            }).catch(err => {
                console.log(err)
                this.$message('提交失败')
            })
        },

        zhuQuByCityId (event, name) {
            // if (event.target.checked) {
            //     this.siIds.push(event.target.value)
            //     this.getCityQuArrayDate(event.target.value)
            // } else {
            //     if (this.siIds.length > 0) {
            //         const currentIndex = this.siIds.indexOf(Number(event.target.value))
            //         if (currentIndex >= 0) {
            //             this.siIds.splice(currentIndex, 1)
            //         }
            //         this.cityQuArray = []
            //     }
            // }
            // alert(event.target.value)
            // const a = this.beijing.forEach((item) => Number(item) === Number(event.target.value))
            // if (a >= 0) {
            //     event.target.value = 12

            // }
            // alert(event.target.value)
            if (event.target.checked) {
                this.siIds.push(Number(event.target.value))
                this.siIdsNameArray.push(name)
                // 判断二级地区数组是否有值
                if (this.cityQuArray.length > 0) {
                    let currentIndex
                    // 遍历二级分类
                    this.cityQuArray.forEach(element => {
                        // 找出对应的父类地区的索引位置
                        currentIndex = element.findIndex((item) => { return item.ShortName === name })
                    })
                    // 有
                    if (currentIndex >= 0) {

                    } else {
                        //
                        this.getCityQuArrayDate(event.target.value)
                    }
                } else {
                    this.getCityQuArrayDate(event.target.value)
                }
            } else {
                if (this.siIds.length > 0) {
                    const currentIndex = this.siIds.findIndex((item) => { return item === Number(event.target.value) })
                    const currentNameIndex = this.siIdsNameArray.findIndex((item) => { return item === name })
                    if (currentIndex >= 0) {
                        this.siIds.splice(currentIndex, 1)
                    }
                    if (currentNameIndex >= 0) {
                        this.siIdsNameArray.splice(currentNameIndex, 1)
                    }
                    // this.cityQuArray = []
                }
                const filterArray = this.siIdsNameArray.filter((item) => {
                    return item === name
                })
                // if (currentIndex >= 0) {
                //     ArrayIndex = index
                // } else {
                //     return
                // }
                if (filterArray.length === 0) {
                    let ArrayIndex
                    this.cityQuArray.forEach(element => {
                        ArrayIndex = element.findIndex((item) => { return item.ShortName === name })
                    })
                    this.cityQuArray.splice(ArrayIndex, 1)
                } else {

                }
            }
            // event.target.value = !event.target.value;
        },
        // 将获取到的区进行拼接
        zhuQuByquId (event) {
            if (event.target.checked) {
                this.quIds.push(Number(event.target.value))
                this.getCityQuArrayDate(event.target.value)
            } else {
                if (this.quIds.length > 0) {
                    const currentIndex = this.quIds.indexOf(Number(event.target.value))
                    if (currentIndex > 0) {
                        this.quIds.splice(currentIndex, 1)
                    }
                    this.cityQuArray = []
                }
            }
        },
        // 获取市底下的区的数组
        getCityQuArrayDate (value) {
            getPmUserInfoMatchCity({
                area: value
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    res.data.Body.forEach(item => {
                        this.quObject = item
                    })
                    if (this.quObject.length > 0) {
                        const current = this.cityQuArray.findIndex((item) => item[0].Name === this.quObject[0].Name)
                        if (current >= 0) {
                            // 有
                        } else {
                            // 无
                            this.cityQuArray.push(this.quObject)
                        }
                    }
                }
            }).catch(err => {
                console.log(err)
            })
        },
        zhuKuaByCityId (event) {
            if (event.target.checked) {
                this.kuaIds.push(Number(event.target.value))
            } else {
                if (this.kuaIds.length > 0) {
                    const currentIndex = this.kuaIds.indexOf(Number(event.target.value))
                    if (currentIndex >= 0) {
                        this.kuaIds.splice(currentIndex, 1)
                    }
                }
            }
        },
        MappingButton () {
            updateUserTypeValueAndAddress({
                uid: this.leftInfo.uid, // uid
                typeValue: this.typeArr.join(','), // 类型
                AddressCityId: this.cityId, // 市id
                AddressProvinceId: this.pemdmert, // 省
                AddressCountyId: this.quName, // 区
                AddressDetail: this.AddressDetail // 具体地址
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    this.updateStageInfoByleIdFn()
                }
            }).catch(err => {
                console.log('添加指定用户的类型和地址失败updateUserTypeValueAndAddress，异常信息：' + err)
            })
        },
        // 添加指定用户的详细地址信息
        updateStageInfoByleIdFn () {
            updateStageInfoByleId({
                uid: this.leftInfo.uid, // 用户id
                address: this.AddressDetail // 具体地址
            }).then(result => {
                if (result.data.StatusCode === 0) {
                    layer.msg('提交成功')
                    this.$router.push(this.$route.matched[1].path)
                }
            }).catch(err => {
                console.log('添加指定用户的详细地址信息失败updateStageInfoByleId，异常信息：' + err)
            })
        },
        PmWorkAreaByUid () {
            let _this = this
            _this.huixian = {}
            getPmWorkAreaByUid({
                uid: this.leftInfo.uid
            }).then(result => {
                this.huixian = result.data.Body
                this.xuanzhong = this.huixian.kuaArea !== undefined ? this.huixian.kuaArea : []
                this.colony = this.huixian.siArea !== undefined ? this.huixian.siArea : []
                this.xiaColony = this.huixian.diArea !== undefined ? this.huixian.diArea : []/* 地区 */
                this.quColony = this.huixian.quSubarea !== undefined ? this.huixian.quSubarea : [] /* 分区 */
                this.currentType = this.huixian.typeValue.typeValue.split(',') /* typeValue='1-100,1-200' */
                this.splitValueType(this.currentType)
                this.arrery = this.currentType
                this.siIds = this.colony
                this.kuaIds = this.xuanzhong
                this.dqIds = this.xiaColony
                // this.quIds = this.quColony
                this.quSubarea = this.quColony

                if (this.dqIds.length === 0) {
                    this.colony = []
                    this.siIds = []
                }
                // if (this.xiaColony.length > 0) {
                //     this.dqIds = this.xiaColony.join(',')
                //     this.dqIds = this.dqIds + ','
                // }
                this.xiaColony.forEach(item => {
                    this.getDiquByCity(item)
                })
                if (this.xiaColony.length > 0) {
                    this.siIds.forEach(item => {
                        this.getCityQuArrayDate(item)
                    })
                }
            })
        },
        // 拆分typeValue
        splitValueType (typeValue) {
            if (typeValue[0][1] !== '-') {
                this.fuIds = typeValue
            } else {
                typeValue.forEach(item => {
                    let fuId = Number(item.split('-')[0])
                    let twoId = Number(item.split('-')[1])
                    const current = this.fuIds.findIndex((item) => Number(item) === Number(fuId))
                    if (current < 0) {
                        this.fuIds.push(Number(fuId))
                        this.getTwoType(fuId)
                    }
                    const currentIndex = this.twoIds.findIndex((item) => Number(item) === Number(twoId))
                    if (currentIndex < 0) {
                        this.twoIds.push(Number(twoId))
                    }
                    this.typeArr = typeValue
                })
            }
        },
        // 父级类型点击显示二级类型
        getTwoTypes (event) {
            let inputDom = document.getElementsByClassName('selBtn')
            if (event.target.checked) {
                // 查询这个value是否在fuIds中出现
                const currentIndex = this.fuIds.indexOf(Number(event.target.value))
                // 判断是否存在
                if (currentIndex >= 0) {

                } else {
                    this.fuIds.push(Number(event.target.value))
                }
                this.getTwoType(event.target.value)
            } else {
                if (this.fuIds.length > 0) {
                    // 查询这个value是否在fuIds中出现
                    const currentIndex = this.fuIds.indexOf(Number(event.target.value))
                    // 判断是否存在
                    if (currentIndex >= 0) {
                        // 如果出现，那么删除这个value值
                        this.fuIds.splice(currentIndex, 1)
                    }
                }
                // 拿到这个value值
                const value = event.target.value
                let ArrayIndex
                this.twoTypeArr.forEach((item, index) => {
                    const currentIndex = item.findIndex((item) => {
                        return Number(item.pid) === Number(value)
                    })
                    if (Number(currentIndex) >= 0) {
                        ArrayIndex = index
                    } else {
                        return false
                    }
                })
                this.twoTypeArr.splice(ArrayIndex, 1)
            }
            if (Number(this.fuIds.length) === 4) {
                for (var j = 0, len3 = inputDom.length; j < len3; j++) {
                    if (!inputDom[j].checked) {
                        inputDom[j].disabled = true
                    }
                }
            }
        },
        // 获取父级分类名称
        getTypeName (pid) {
            let arr = this.workType
            var name
            // debugger
            for (let i = 0; i < arr.length; i++) {
                if (Number(arr[i].id) === Number(pid)) {
                    name = arr[i].name
                }
            }
            return name
        },
        // 每点一个就拼接一次
        getTypeValues (event, pid) {
            // 将父级类型id赋值给fuId
            // let fuId = pid
            // 二级id
            let twoId = event.target.value
            let fuId = pid + ''
            let type
            type = fuId + '-' + twoId
            // 判断是否被选中
            if (event.target.checked) {
                // 添加到二级类型的数组中
                // this.twoIds.push(Number(twoId))
                // 判断父类型的id数组中是否有pid
                // const currentIndex = this.fuIds.findIndex((item) => { return Number(item) === Number(pid) })
                // // 判断上面变量是否大于等于0
                // if (currentIndex < 0) {
                // // 没有pid，将pid添加到父级id数组中
                //     this.fuIds.push(pid)
                // }
                // 判断typeArr中是否有type这个元素
                const current = this.typeArr.findIndex((item) => { return Number(item) === Number(type) })
                if (current < 0) {
                    this.typeArr.push(type)
                }
            } else {
                // debugger
                // 判断typeArr中是否有type这个元素
                const current = this.typeArr.findIndex((item) => { return item === type })
                if (current >= 0) {
                    this.typeArr.splice(current, 1)
                }
                // 未选中，判断二级分类的id数组是否为空
                // if (this.twoIds.length > 0) {
                //     // 判断二级分类数组中是否有这个二级id
                // const currentIndex = this.twoIds.findIndex((item) => { return Number(item) === Number(event.target.value) })
                // if (currentIndex >= 0) {
                // this.twoIds.splice(currentIndex, 1)
                // }
                //     // 删除之后判断二级分类id的数组是否有值
                //     if (this.twoIds.length === 0) {
                //         this.twoIds = []
                //         // 无值则删除pid
                //         // 判断父类型的id数组中是否有pid
                //         const currentIndex1 = this.fuIds.findIndex((item) => { return Number(item) === Number(pid) })
                //         // 判断上面变量是否大于等于0
                //         if (currentIndex1 >= 0) {
                //             this.fuIds.splice(currentIndex1, 1)
                //         }
                //     }
                // } else {
                //     // 如果为空，删除父级类型的id
                //     // 判断父类型的id数组中是否有pid
                //     const currentIndex = this.fuIds.findIndex((item) => { return Number(item) === Number(pid) })
                //     // 判断上面变量是否大于等于0
                //     if (currentIndex >= 0) {
                //         this.fuIds.splice(currentIndex, 1)
                //     }
                // }
            }
            // console.log(this.typeArr)
            // 将父id和对应的二级id用-和,拼接，比如  1-100,1-101,   放到typeArr，如果twoIds为空就从typeArr中删除有关的数据
            // this.joinTypes(pid, twoId)
        },
        // 拼接所有的类型
        // joinTypes (pid, twoId) {
        // 判断父级id的数组是否为空，为空，提交失败
        // if (this.fuIds.length === 0) {
        //     layer.msg('提交失败')
        //     return
        // }
        // 判断二级类型的id数组是否未空
        // if (twoIds.length === 0 && this.typeArr.length > 0) {
        //     // 判断typeArr是否有该pid，有删除pid的相关数据
        //     for (let index = 0; index < this.typeArr.length; index++) {
        //         const element = twoIds[index]
        //         if (Number(element.split('-')[0]) === Number(pid)) {
        //             this.typeArr.splice(index, 1)
        //         }
        //     }
        // } else if (twoIds.length !== 0) {
        //     // let type
        //     let fuId = pid + ''
        //     // let twoId
        //     twoIds.forEach(item => {
        //         let twoId = item + ''
        //         let type = fuId + twoId
        //         this.typeArr.push(type)
        //     })
        // }
        //     let type
        //     let fuId = pid + ''
        //     // let twoId = twoId + ''
        //     type = fuId + '-' + twoId
        //     if () {
        //     }
        // },
        workTypeArray () {
            this.workType = [{
                flag: false,
                name: '办公',
                id: 1
            }, {
                flag: false,
                name: '餐饮',
                id: 2
            }, {
                flag: false,
                name: '商业',
                id: 3
            }, {
                flag: false,
                name: '酒店',
                id: 4
            }, {
                flag: false,
                name: '教育',
                id: 6
            }, {
                flag: false,
                name: '会所',
                id: 7
            }, {
                flag: false,
                name: '家装',
                id: 8
            }, {
                flag: false,
                name: '别墅',
                id: 9
            }]
        }


    }
}

</script>
